package com.threegroup.admin.service.impl;

import com.threegroup.admin.dao.SysDictDataDao;
import com.threegroup.admin.dao.SysDictTypeDao;
import com.threegroup.admin.entity.DictData;
import com.threegroup.admin.entity.DictType;
import com.threegroup.admin.service.ISysDictTypeService;
import com.threegroup.common.utils.Result;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysDictTypeServiceImpl implements ISysDictTypeService {

    @Resource
    private SysDictTypeDao sysDictTypeDao;

    @Resource
    private SysDictDataDao sysDictDataDao;

    @Override
    public List<DictType> getAllList() {
        List<DictType> typeList = sysDictTypeDao.getDictTypeList();
        List<DictData> dataList = sysDictDataDao.getDictDataList();
        for(DictType type : typeList){
            for(DictData data : dataList){
                if(type.getId().equals(data.getDictTypeId())){
                    type.getDataList().add(data);
                }
            }
        }
        return typeList;
    }
}
